<?php

    header('Cache-Control: no-cache, no-store, must-revalidate'); // HTTP 1.1.
    header('Pragma: no-cache'); // HTTP 1.0.

    include 'database.php';


//execute the SQL query and return records
$result = mysql_query("SELECT id, categoryID, question, answer FROM QuizQuestions");

$rows = array();
while($r = mysql_fetch_assoc($result)) {
    $rows[] = $r;
}

$results = array_map(function($r) {
                         $r['question'] = base64_encode(utf8_encode($r['question']));
                         $r['answer'] = base64_encode(utf8_encode($r['answer']));
                         return $r;
                         }, $rows);
    
$str = json_encode($results);
echo $str;
mysql_close($dbhandle);

?>